/**
 * 
 */
package cn.edu.hstc.ui;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import cn.edu.hstc.R;
import cn.edu.hstc.common.L;
import cn.edu.hstc.ui.fragment.UserInfo;
import cn.edu.hstc.ui.fragment.UserSchedule;
import cn.edu.hstc.ui.fragment.UserScore;

/**
 * @Description 放置所有的教务系统的内容 的Fragment的容器,由{@link JwglMain.class}进入不同的内容显示
 * @author act262
 * @version 1.0
 * @since 2014-5-2 下午2:17:02
 * 
 */
public class JwglDetail extends FragmentActivity {

	private final String TAG = JwglDetail.class.getSimpleName();

	public void onCreate(Bundle bundle) {
		super.onCreate(bundle);
		setContentView(R.layout.jwgl_detail);
		L.d(TAG, "onCreate task id = " + getTaskId());
		initContent();
	}

	/**
	 * 根据传入的来源使用指定的Fragment显示内容
	 */
	private void initContent() {
		// 取出传递的数据
		Bundle bundle = getIntent().getExtras();
		switch ((JwglMain.JwglContentType) getIntent().getSerializableExtra(JwglMain.JWGL_CONTENT_INTENT_TYPE)) {

		// 显示用户信息
		case UserInfo:
			showFragment(UserInfo.getInstance(bundle));
			break;

		// 显示用户课程表
		case Schedule:
			showFragment(UserSchedule.getInstance(bundle));
			break;

		case UserScore:
			showFragment(UserScore.getInstance(bundle));
			break;
		default:
			break;
		}
	}

	private void showFragment(Fragment fragment) {
		FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
		transaction.replace(R.id.fl_jwgl_detail_content, fragment);
		transaction.commit();
	}
}
